function loadXMLDoc(dname) {
	if (window.ActiveXObject) {
		xhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
	} else {
		xhttp = new XMLHttpRequest();
	}
	xhttp.open("GET", dname, false);
	xhttp.send("");
	return xhttp.responseXML;
}

function displayResult(xslToUse, idOfDivWhereIwillPutTheHTML) {
	xsl = loadXMLDoc(xslToUse);
	xml = loadXMLDoc("../xml/rudineiLattes.xml");
	// code for IE
	if (window.ActiveXObject) {
		ex = xml.transformNode(xsl);
		document.getElementById(idOfDivWhereIwillPutTheHTML).innerHTML = ex;

	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument) {
		xsltProcessor = new XSLTProcessor();
		xsltProcessor.importStylesheet(xsl);
		resultDocument = xsltProcessor.transformToFragment(xml, document);

		last = document.getElementById(idOfDivWhereIwillPutTheHTML).childNodes[0];
		document.getElementById(idOfDivWhereIwillPutTheHTML).insertBefore(
				resultDocument, last);
	}
}

function removingExtraHtml(idOfDivWhereIwillPutTheHTML) {
	last = document.getElementById(idOfDivWhereIwillPutTheHTML).childNodes[0];
	document.getElementById(idOfDivWhereIwillPutTheHTML).removeChild(last);
}

$("#retorna_publicacoes").bind("click", function() {
	removingExtraHtml("html_publicacao");
});

$("#retorna_completo").bind("click", function() {
	removingExtraHtml("html_completo");
});

$("#retorna_orientacoes").bind("click", function() {
	removingExtraHtml("html_orientacao");
});

$("#completo").bind("click", function() {
	displayResult("../xml/rudineiLattesCompleto.xsl", "html_completo");
});

$("#orientacoes").bind("click", function() {
	displayResult("../xml/rudineiLattesOrientacoes.xsl", "html_orientacao");
});

$("#publicacoes").bind("click", function() {
	displayResult("../xml/rudineiLattesPublicacoes.xsl", "html_publicacao");
});
